﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;


namespace Quest
{
    abstract class Enemy: Mover
    {
        // enhancement #1: Make the enemies smarter
        //private const int NearPlayerDistance = 25;
        private int NearPlayerDistance;
        protected Levels level;
        public Levels Level { get{ return level;}  set{ level = value;} }

        private int hitPoints;
        public int HitPoints { get { return hitPoints; } }

        // enhancement #1: Make the enemies smarter
        private Dictionary<Levels, int> NearPlayerDistances = new Dictionary<Levels, int>()
        {
            {Levels.Low, 25},
            {Levels.Medium, 35},
            {Levels.High, 50}
        };



        // enhancement #1: Make the enemies smarter
        //public Enemy (Game game, Point point, int hitPoints): base(game, point)
        public Enemy(Game game, Point point, Levels level, int hitPoints)
            : base(game, point)
        {
            this.hitPoints = hitPoints;
//            this.hitPoints = LevelsHitPoints[level];
            NearPlayerDistance = NearPlayerDistances[level]; // enhancement #1: Make the enemies smarter

            this.level = level;
        }

        public abstract void Move(Random random);

        public void Hit(int maxDamage, Random random)
        {
            hitPoints -= random.Next(1, maxDamage);
        }

        protected bool NearPlayer()
        {
            return Nearby(game.PlayerLocation, NearPlayerDistance);
        }

        protected Direction FindPlayerDirection(Point opponentLocation)
        {
            Direction directionToMove;
            if (opponentLocation.X > location.X + 10)
                directionToMove = Direction.Right;
            else if (opponentLocation.X < location.X - 10)
                directionToMove = Direction.Left;
            else if (opponentLocation.Y < location.Y - 10)
                directionToMove = Direction.Up;
            else
                directionToMove = Direction.Down;
            return directionToMove;
        }
    }
}
